package com.haircut.project.controller.config;

import com.haircut.project.service.config.IConfigService;
import com.haircut.project.vo.catetory.CategoryTreeVo;
import com.haircut.project.vo.config.ConfigReqVo;
import com.haircut.project.vo.config.ConfigResVo;
import com.haircut.project.vo.config.ConfigSttVo;
import com.haircut.project.vo.config.ConfigVo;
import com.modular.result.PageResult;
import com.modular.result.RspMessage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/b/project/config")
public class ConfigController {
    @Autowired
    private IConfigService configService;
    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "查询分类列表")
    @PostMapping("findPage")
    public RspMessage<PageResult<ConfigResVo>> findPage(@RequestBody ConfigReqVo reqVo){
        return RspMessage.success(configService.findPage(reqVo));
    }

    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "保存配置")
    @PostMapping("saveConfig")
    public RspMessage<Void> saveConfig(@Validated  @RequestBody ConfigVo reqVo){
        configService.save(reqVo);
        return RspMessage.success();
    }
    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "修改配置")
    @PostMapping("modifyConfig")
    public RspMessage<Void> modifyConfig(@Validated  @RequestBody ConfigVo reqVo){
        configService.mdoify(reqVo);
        return RspMessage.success();
    }
    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "删除配置")
    @GetMapping("delConfig")
    public RspMessage<Void> delConfig(@ApiParam("configId") @RequestParam("configId") String configId){
        configService.delConfig(configId);
        return RspMessage.success();
    }
    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "修改状态")
    @PostMapping("modifyStts")
    public RspMessage<Void> modifyStts(@Validated  @RequestBody ConfigSttVo reqVo){
        configService.modifyStts(reqVo);
        return RspMessage.success();
    }
}
